package com.cloudpan.common.exception;

import com.cloudpan.common.R;
import com.cloudpan.common.ResultCodeMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author sc
 * @DATE 2023/11/10 14:15
 * @Description:
 * @Version 1.0
 */
@RestControllerAdvice
@Slf4j
@RestController
public class GloBalExceptionController {

    @ExceptionHandler(GlobalExceptionHandler.class)
    public R GlobalExceptionHandler(GlobalExceptionHandler e){
        log.info("异常为:{}",e.getMessage());
        return R.failed(e.getMessage()).setCode(ResultCodeMsg.FAIL.getCode());
    }
}
